package com.xinqing.test.LetCode;

import java.util.HashMap;
import java.util.HashSet;
import java.util.List;

/**
 * @Author:CHQ
 * @Date:2021/7/20 14:55
 * @Description
 */
public class SearchRange {
    public  static void main(String[] args){
        int[] nums={1,2,2,3,4,5,6};
        int[] res=test(nums);
        for(int x:res){
            System.out.print(x+" ");
        }
    }
    public static int[] test(int[] nums){
        HashMap<Integer,Integer> map=new HashMap<>();
        for(int i=0;i<nums.length;i++){
            if(map.containsKey(nums[i])){
                return new int[]{map.get(nums[i]),i};
            }
            map.put(nums[i],i);
        }
        return new int[]{-1,-1};
    }
}
